#include <iostream>
#include <vector>
#include <Vector.hpp>
using namespace std;

class Solution
{
public:
    void rotate(vector<vector<int>> &matrix)
    {
        int width = matrix[0].size();
        int height = matrix.size();
        int ex = (width + 1) / 2;
        int ey = height / 2;
        for (int x = 0; x < ex; x++)
        {
            for (int y = 0; y < ey; y++)
            {
                swap(matrix[y][x], matrix[x][width - 1 - y]);                           // 12
                swap(matrix[y][x], matrix[height - 1 - x][y]);                          // 14
                swap(matrix[height - 1 - x][y], matrix[height - 1 - y][width - 1 - x]); // 34
            }
        }
    }
};
int main()
{
    cout << "Code48" << endl;
    Solution s;
    //std::vector<vector<int>> matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
    std::vector<vector<int>> matrix = {{5, 1, 9, 11}, {2, 4, 8, 10}, {13, 3, 6, 7}, {15, 14, 12, 16}};
    s.rotate(matrix);
    Print2DVector(matrix);
    return 0;
}